from django.db import models


# Create your models here.
class WalletInfo(models.Model):
    # 钱包信息表
    WALLET_STATUS = (
        (0, '正常'),
        (1, '封禁'),
    )
    phone = models.CharField(max_length=11, unique=True, null=False, verbose_name='手机号')
    balance = models.DecimalField(max_digits=10, decimal_places=2, unique=False, null=False, default=0.00, verbose_name='钱包余额')
    frozen_balance = models.DecimalField(max_digits=10, decimal_places=2, unique=False, null=False, default=0.00, verbose_name='冻结金额')
    wallet_code = models.CharField(max_length=68, unique=True, null=False, verbose_name='钱包编号')
    wallet_status = models.SmallIntegerField(choices=WALLET_STATUS, unique=False, null=False, default=0, verbose_name='钱包状态')
    crated_time = models.DateTimeField(unique=False, null=False, verbose_name='创建时间')
    updated_time = models.DateTimeField(unique=False, null=False, verbose_name='更新时间')

    class Meta:
        db_table = 'wallet_info'
        verbose_name = '钱包信息表'
        verbose_name_plural = verbose_name


class WalletWithdrawAccount(models.Model):
    # 提现账户表
    phone = models.CharField(max_length=11, null=False, verbose_name='手机号')
    withdraw_way_code = models.CharField(max_length=20, null=False, verbose_name='提现方式')
    withdraw_account = models.CharField(max_length=100, null=True, verbose_name='提现账户')
    withdraw_count = models.IntegerField(null=False, verbose_name='提现次数')
    created_time = models.DateTimeField(null=False, verbose_name='创建时间')
    updated_time = models.DateTimeField(null=False, verbose_name='更新时间')

    class Meta:
        db_table = 'wallet_withdraw_account'
        verbose_name = '提现账户管理'
        verbose_name_plural = verbose_name


class WalletWithdrawRecord(models.Model):
    # 提现记录表
    WITHDRAW_STATUS = (
        (0, '提现中'),
        (1, '提现成功'),
        (2, '提现失败')
    )
    phone = models.CharField(max_length=11, null=False, verbose_name='手机号')
    wallet_code = models.CharField(max_length=20, null=False, verbose_name='钱包编号')
    withdraw_account = models.CharField(max_length=68, null=False, verbose_name='提现账户')
    withdraw_no = models.CharField(max_length=68, null=False, verbose_name='提现记录编号')
    withdraw_status = models.IntegerField(choices=WITHDRAW_STATUS, null=False, verbose_name='提现状态(提现进度)')
    amount = models.DecimalField(max_digits=10, decimal_places=2, null=False, verbose_name='提现金额')
    service_rate = models.DecimalField(max_digits=10, decimal_places=2, null=False, verbose_name='服务税率')
    remit_amount = models.DecimalField(max_digits=10, decimal_places=2, null=True, verbose_name='实际提现到账金额')
    apply_remark = models.CharField(max_length=128, null=True, verbose_name='申请备注')
    refused_remark = models.CharField(max_length=128, null=True, verbose_name='提现失败原因')
    check_time = models.DateTimeField(null=True, verbose_name='审核时间')
    remit_time = models.DateTimeField(null=True, verbose_name='放款时间')
    created_time = models.DateTimeField(null=False, verbose_name='创建时间')
    updated_time = models.DateTimeField(null=False, verbose_name='更新时间')

    class Meta:
        db_table = 'wallet_withdraw_record'
        verbose_name = '提现记录'
        verbose_name_plural = verbose_name


class WalletRecord(models.Model):
    # 提现记录表
    TRADE_TYPE = (
        ('out', '出账'),
        ('in', '入账'),
    )
    phone = models.CharField(max_length=11, null=False, verbose_name='手机号')
    wallet_code = models.CharField(max_length=20, null=False, verbose_name='钱包编号')
    trade_type = models.CharField(max_length=10, choices=TRADE_TYPE, null=False, verbose_name='流水类型')
    trade_no = models.CharField(max_length=68, null=False, verbose_name='流水编号')
    order_no = models.CharField(max_length=68, null=False, verbose_name='订单编号')
    withdraw_record_no = models.CharField(max_length=68, null=False, verbose_name='提现记录编号')
    trade_remark = models.TextField(verbose_name='流水备注')
    created_time = models.DateTimeField(null=False, verbose_name='创建时间')
    updated_time = models.DateTimeField(null=False, verbose_name='更新时间')

    class Meta:
        db_table = 'wallet_record'
        verbose_name = '钱包流水'
        verbose_name_plural = verbose_name
